﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace ElingOA6_Admin_DSJCJ.BLL
{
    /// <summary>
    /// 业务逻辑类ItemYearBal
    /// </summary>
    public partial class ItemYearBal
    {
        /// <summary>
        /// 组织机构dal
        /// </summary>
        private readonly DAL.ItemYearBal dal = new DAL.ItemYearBal();
        /// <summary>
        ///  获得数据列表
        /// <summary>
        /// <creator>chenly</creator>
        /// <date>2013-9-24</date>
        /// </summary>
        /// <param name="dt">一张DataTable</param>
        /// <returns>返回Model</returns>
        public List<Model.ItemYearBal> DataTableToListItemYearBal(DataTable dt)
        {
            List<Model.ItemYearBal> modelList = new List<Model.ItemYearBal>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                Model.ItemYearBal model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new Model.ItemYearBal();
                    if (dt.Rows[n]["FItemName"] != null)
                    {
                        model.FItemName = dt.Rows[n]["FItemName"].ToString();
                    }
                    if (dt.Rows[n]["FYear"] != null && dt.Rows[n]["FYear"].ToString() != "")
                    {
                        model.FYear = decimal.Parse(dt.Rows[n]["FYear"].ToString());
                    }
                    if (dt.Rows[n]["FItemNo"] != null)
                    {
                        model.FItemNo = dt.Rows[n]["FItemNo"].ToString();
                    }
                    if (dt.Rows[n]["FPrice"] != null && dt.Rows[n]["FPrice"].ToString() != "")
                    {
                        model.FPrice = decimal.Parse(dt.Rows[n]["FPrice"].ToString());
                    }
                    if (dt.Rows[n]["FEntityNo"] != null)
                    {
                        model.FEntityNo = dt.Rows[n]["FEntityNo"].ToString();
                    }
                    if (dt.Rows[n]["FQty"] != null && dt.Rows[n]["FQty"].ToString() != "")
                    {
                        model.FQty = decimal.Parse(dt.Rows[n]["FQty"].ToString());
                    }
                    if (dt.Rows[n]["FAmount"] != null && dt.Rows[n]["FAmount"].ToString() != "")
                    {
                        model.FAmount = decimal.Parse(dt.Rows[n]["FAmount"].ToString());
                    }
                    modelList.Add(model);
                }
            }
            return modelList;
        }
        ///// <summary>
        ///// 增加一条数据
        ///// </summary>
        ///// <param name="model">model对象</param>
        ///// <returns>增加</returns>
        //public bool Add(Model.ItemYearBal model)
        //{
        //    return dal.Add(model);
        //}

        ///// <summary>
        ///// 是否存在该记录
        ///// </summary>
        ///// <param name="year">年度</param>
        ///// <param name="itemNo">用品编号</param>
        ///// <param name="entityNo">公司编号</param>
        ///// <returns>是否存在</returns>
        //public bool Exists(decimal year, string itemNo, string entityNo)
        //{
        //    return dal.Exists(year, itemNo, entityNo);
        //}

        /// <summary>
        /// 更新一条数据
        /// </summary>
        /// <param name="model">model对象</param>
        /// <returns>是否更新</returns>
        public void Update(Model.ItemYearBal itemYearBalModel, Model.Item itemModel)
        {
            dal.Update(itemYearBalModel, itemModel);
        }




        public DataSet GetAllList(string where)
        {
            return dal.GetAllList(where);
        }




    }
}
